<@pp.dropOutputFile/>
<#include "../common/util.ftl">
<#-- iterate table list-->
<#list doc.tables as table>

<#-- generate package name -->
<#assign app = doc.artifactid?replace(".", "/")>
<#assign package = table.moduleid?replace(".", "/")>
<#assign fileName = table.name?cap_first>
<@pp.changeOutputFile name = "/" + package  + "/View/" + fileName + "ReportForm.vb"/>
<#assign package = table.moduleid?replace("/", ".")>
Imports Microsoft.Reporting.WinForms
Imports ${app}.${package}

Public Class ${fileName}ReportForm
    Private _${fileName}Service As I${fileName}Service = Nothing
	Public Property DB As IDbConnection

    Private Sub ${fileName}ReportForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        _${fileName}Service = New ${fileName}ServiceSqliteImpl(_DB)
		Dim objs As List(Of ${fileName}) = _${fileName}Service.getPage(0, 10, Nothing).Data
        ReportViewer1.LocalReport.ReportEmbeddedResource = "${app}.${fileName}Report.rdlc"
        ReportViewer1.LocalReport.SetParameters(New ReportParameter("table_comment", "<#if table.comment??>${table.comment}<#else>${table.name}</#if>"))
		ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("ds", objs))
		
		'Dim obj As ${fileName} = _${fileName}Service.getOne(params).Data
        '_${fileName}Service.loadOne(obj)

        'ReportViewer1.LocalReport.ReportEmbeddedResource = "Neutron_core.${fileName}Report.rdlc"
		<#list table.fields as field>
        'ReportViewer1.LocalReport.SetParameters(New ReportParameter("${field.name}", obj.{field.name?cap_first}))
		</#list>
		
        Me.ReportViewer1.RefreshReport()
    End Sub
End Class
</#list>